package fr.vahren.sriksal.dao.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import fr.vahren.sriksal.controller.bean.MapTile.Biome;
import fr.vahren.sriksal.controller.bean.MapTile.Elevation;
import fr.vahren.sriksal.dao.bean.TileDaoBean;

public class TileRowMapper implements RowMapper<TileDaoBean> {

	@Override
	public TileDaoBean mapRow(ResultSet rs, int arg1) throws SQLException {
		TileDaoBean bean = new TileDaoBean();
		bean.setBiome(Biome.valueOf(rs.getString("BIOME")));
		bean.setElevation(Elevation.valueOf(rs.getString("ELEVATION")));
		bean.setHasTown("O".equals(rs.getString("HAS_TOWN")));
		bean.setMapId(rs.getLong("ID_MAP"));
		bean.setTileId(rs.getLong("ID_TILE"));
		bean.setX(rs.getInt("X"));
		bean.setY(rs.getInt("Y"));
		return bean;
	}

}
